DXL Script - Emails Employee when a Module is updated.

Hello everyone, I am working on my first DXL script for DOORS. I do have some small background in other languages, but I was given an assignment at work with DXL and I need some help getting started on this code.

Basically within DOORS, a project engineer will be updating a Module with information about the project. It will have the assignment, due date, and who is is assigned to.

I need to write a script that will automatically email the person who has an assigned duty when it has been inputted. Also it will need to email the person IF anything related to that assignment has been updated (ie due date). However it cannot email the person everytime the module is updated (such as if the project engineer adds other information for another persons assignment).

Does anyone have a sample script of something like this? Any help would be most appreciated.

Thank you
Matt
m.sprague - Wed Apr 18 11:57:29 EDT 2012

Re: DXL Script - Emails Employee when a Module is updated.
llandale - Wed Apr 18 13:50:10 EDT 2012

You picked a tricky one to start.

First, you'll need to decide what kind of script it will be, On-Demand or Triggering as the Admin makes the changes. 2nd, you need to decide if the current Client will be sending email directly through Outlook, or if you will attempt to configure DOORS to use Email and then make DXL calls to send the email.

I would be very tempted to make it an On-Demand script scheduled to run batch at 12:01am, which opens that module, finds all changes made yesterday, and goes from there. This script can find all Object's whose Last Modified Date was yesterday, extract the user, and place all the changes into a Skip list KEY of username. Then plow through the Skip, convert name to email, and go from there.

Another reasonable On-Demand script would be for the Admin, who after making a change, would push a button, and the info of the current Object is sent to the target user.

A trigger firing script will need to decide exactly which "event" will trigger the program. I doubt your users want a separate Email every time any change is made; so if the Admin changes THIS to THAT and then correct it to THEN, the user would get 2 emails. I would probably make it a pre-close-module trigger looking for History changes made during the current Session. Convert those to Objects and proceed as above.

As for the send part, search for "fEmail_Outlook_CreateMail" in these forums for a rather complicated interface for DOORS to send email through Outlook. I'm sure there is a better way but that is what I came up with. I don't recall how to configure DOORS to send emails, but I suspect that method is better (you call "sendEmailNotification()") since its probably application independant and communicates directly with the Email server.

-Louie

Re: DXL Script - Emails Employee when a Module is updated.
m.sprague - Fri Apr 20 15:12:00 EDT 2012

llandale - Wed Apr 18 13:50:10 EDT 2012
You picked a tricky one to start.

First, you'll need to decide what kind of script it will be, On-Demand or Triggering as the Admin makes the changes. 2nd, you need to decide if the current Client will be sending email directly through Outlook, or if you will attempt to configure DOORS to use Email and then make DXL calls to send the email.

I would be very tempted to make it an On-Demand script scheduled to run batch at 12:01am, which opens that module, finds all changes made yesterday, and goes from there. This script can find all Object's whose Last Modified Date was yesterday, extract the user, and place all the changes into a Skip list KEY of username. Then plow through the Skip, convert name to email, and go from there.

Another reasonable On-Demand script would be for the Admin, who after making a change, would push a button, and the info of the current Object is sent to the target user.

A trigger firing script will need to decide exactly which "event" will trigger the program. I doubt your users want a separate Email every time any change is made; so if the Admin changes THIS to THAT and then correct it to THEN, the user would get 2 emails. I would probably make it a pre-close-module trigger looking for History changes made during the current Session. Convert those to Objects and proceed as above.

As for the send part, search for "fEmail_Outlook_CreateMail" in these forums for a rather complicated interface for DOORS to send email through Outlook. I'm sure there is a better way but that is what I came up with. I don't recall how to configure DOORS to send emails, but I suspect that method is better (you call "sendEmailNotification()") since its probably application independant and communicates directly with the Email server.

-Louie

> llandale wrote:
>
> I would be very tempted to make it an On-Demand script scheduled to run batch at 12:01am, which opens that module, finds all changes made yesterday, and goes from there. This script can find all Object's whose Last Modified Date was yesterday, extract the user, and place all the changes into a Skip list KEY of username. Then plow through the Skip, convert name to email, and go from there.
> -Louie

Lets start with this. This is exactly what I want. So I want to make a skip list and search through the entire module to find an updated object with a corresponding name. Then I want to convert it to an email address.

I have been looking through some info on these boards, but if you have some first hand guidance I would be more than appreciative.

Thanks for your help
Matt

Re: DXL Script - Emails Employee when a Module is updated.
llandale - Sat Apr 21 15:54:11 EDT 2012

m.sprague - Fri Apr 20 15:12:00 EDT 2012
> llandale wrote:
>
> I would be very tempted to make it an On-Demand script scheduled to run batch at 12:01am, which opens that module, finds all changes made yesterday, and goes from there. This script can find all Object's whose Last Modified Date was yesterday, extract the user, and place all the changes into a Skip list KEY of username. Then plow through the Skip, convert name to email, and go from there.
> -Louie

Lets start with this. This is exactly what I want. So I want to make a skip list and search through the entire module to find an updated object with a corresponding name. Then I want to convert it to an email address.

I have been looking through some info on these boards, but if you have some first hand guidance I would be more than appreciative.

Thanks for your help
Matt

Let me think outloud.

Skip g_skpUsers // KEY: 'string' NameUser; DATA: embedded 'Skip' skpChanges
                // embedded skpChanges: KEY: 'int' sequencer; DATA: 'string' blurb about each Object change of interest to this User
int  g_Sequencer = 0
 
for each item in Project
    if its not a formal module then continue
        if it wasn't changed yesterday then continue // actually, since the last time this script ran
        Open Module read
        for each Object
                if it wasn't changed yesterday continue
                bufBlurb = Identifier and Paragraph Number and Last Modified By and On
                for each History in the Object
                   if History wasn't yesterday then continue
                   if I don't care about this History then continue
                   bufBlurb += add short summary of this History change including attrname
                end
                for each NameUser who cares about this object
                   if this NameUser is not yet in g_skpUsers
                      skpChanges = create()
                      put(g_skpUsers, NameUser, skpChanges)
                   put(skpChanges, g_Sequencer++, stringOf(bufBlurb))
                end
        end
        close(mod)
end
for skpChanges in g_skpUsers do
        NameUser = (string key g_skpUsers)
        if not existsUser(NameUser) then no such user
        usr = find(NameUser)
        Email = usr.email
        bufEmail = ""
        for each Blurb in skpChanges
                bufEmail += Blurb
        Create/Send email to this user
end


You'd need to investigate of all desired changes in fact update the Last Modified On attributes of the module and the Object; I wonder about link creation/modification/deletion.

Windows Scheduled Tasks lets you schedule this to run at 12:01am, but you've got the problem of hard-coding user names and passwords to make that happen.

By policy then, users must maintain valid Emails in the user Options.

-Louie

Those of us with OCD-ADHD would have some week-end script sending out notifications of what happened last week. We would also have a couple attr-DXL, one showing changes in the last 30 hours and another in the last 8 days; stored in a view filtered on whether either had any value and the object applied to the current User.

Another reasonable approach would be to have a database wide pre-close-module trigger that finds and summarizes all the changes and stores them into some Config file. Then this nightly script would not need to spend a lot of time opening modules, it would just read (and erase) the Config file to get the individual changes. The couple extra seconds to close a changed module would hardly be noticeable. That trigger could get the current session, then scan through Module history looking for History associated with that session.